// Small example of what a driver should do...

#include "smse2kincludes.h"
#include "StubDriver.h"
#include "cpufactory.h"
#include "SoundDevicefactory.h"


int CStubDriver::Load(const char* fn) {
	Msg("Core -> Driver: I want you to load %s\n",fn);

	// Load the file here.

	Msg("Driver -> Core: I've loaded that file, get the CHardware ready for me\n");

	return 0; // No errors.
}

int CStubDriver::Init(CHardware* hard) {
	ICpu* DummyCpu = CPUFactory("Z80");
	ISoundDevice* DummySnd = SoundDeviceFactory("DummySound");

	// Init the hardware first!
	Msg("Core -> Driver: Initialize this hardware for me.\n");

	if (!DummyCpu) {
		Msg("Driver -> Core: I couldn't find or create DummyCpu\n");
		return 1;
	}

	if (!DummySnd) {
		Msg("Driver -> Core: I couldn't find or create DummySnd\n");
		return 1;
	}

	// Assign stuff to CHardware here. We can keep track of them by ID, or by interface,
	// here we're keeping track of them by ID

	this->cpuid = hard->AddCpu(DummyCpu);
	this->sndid = hard->AddSound(DummySnd);

	if (cpuid < 0) {
		Msg("Driver -> Core: I couldn't add the CPU to the hardware!\n");
		return 1;
	}

	if (sndid < 0) {
		Msg("Driver -> Core: Couldn't assign DummySnd to hardware!\n");
		return 1;
	}

	return 0;
}


void CStubDriver::Close() {
	Msg("Core -> Driver: I have everything I want from you, thanks for your help\n");

	// We close unneeded resources such as the file and temporary blobs of memory here.
	// The driver instance is then freed, and we're all done with this.
}
void CStubDriver::FreeUnusedResources() {

}
